<template>
    <div>
        <!-- 头部 -->
        <v-top></v-top>
        <v-banner></v-banner>
        <div class="load">
            <div class="max">
                <ul>
                    <li>位置</li>
                    <li @click="go('/')">首页</li>
                    <li @click="go('/newList')">列表</li>
                    <li>
                        招标公告
                    </li>
                </ul>
            </div>
        </div>
        <div class="max" style="padding: 0 50px;">
            <a-form>
                <a-row :gutter="[24,0]">
                    <a-col :span="12">
                        <a-form-item label="关键字">
                            <a-input v-model:value="params.bidingName" placeholder="请输入关键字">
                            </a-input>
                        </a-form-item>
                    </a-col>
                    <!--                    <a-col :span="12">-->
                    <!--                        <a-form-item label="发布时间">-->
                    <!--                            <a-range-picker :placeholder="['起始时间','截止时间']" style="width: 100%;" v-model:value="params.fieldB" format="YYYY/MM/DD" />-->
                    <!--                        </a-form-item>-->
                    <!--                    </a-col>-->
                    <!--                    <a-col :span="12">-->
                    <!--                        <a-form-item label="截止时间">-->
                    <!--                            <a-range-picker :placeholder="['起始时间','截止时间']" style="width: 100%;" v-model:value="params.fieldB" format="YYYY/MM/DD" />-->
                    <!--                        </a-form-item>-->
                    <!--                    </a-col>-->
                    <a-col :span="12">
                        <a-form-item style="float: right;">
                            <a-button
                                type="primary"
                                @click="getDataSource"
                            >
                                搜索
                            </a-button>
                        </a-form-item>
                    </a-col>
                </a-row>
            </a-form>
        </div>
        <a-table
            :customRow="customRow"
            :rowKey="(record,index)=>{return index}"
            @change="onChange(pagination)"
            :pagination="pagination"
            :showHeader="false"
            class="max"
            :columns="columns"
            :data-source="dataSource"
        >
        </a-table>
        <!-- 底部 -->
        <v-footer></v-footer>
    </div>
</template>

<script>
    import footer from "@/components/foot";
    import top from "@/components/top";
    import banner from "@/components/banner";
    import {defineComponent, reactive, toRefs} from "vue";
    import {getChangeAnnouncement} from "../request/api/sys";

    export default defineComponent({
        components: {
            "v-footer": footer,
            "v-top": top,
            "v-banner": banner,
        },
        data () {
            return {
                formItemLayout: {},
                columns: [
                    {
                        title: '招标地',
                        dataIndex: 'agentAddr'
                    },
                    {
                        title: '招标方式',
                        dataIndex: 'bidingWay'
                    },
                    {
                        title: '项目名称',
                        dataIndex: 'bidingTitle'
                    },
                    {
                        title: '截止时间',
                        dataIndex: 'bidOpenTime'
                    },
                ],
                dataSource: [],
                pagination: {
                    total: 0
                },
                params: {
                    pageNum: 1,
                    pageSize: 10
                }
            }
        },
        created() {
            // 获取变更公告
            this.getDataSource();
        },

        methods: {
            customRow(record) {
                return {
                    onClick: (event) => {
                        this.$router.push({path: `/noticeList2/${record.bidingId}`})
                    }
                }
            },
            onChange (pagination) {
                this.params.pageNum = pagination.current
                this.getDataSource()
            },
            // 获取变更公告
            getDataSource() {
                getChangeAnnouncement(this.params).then((res) => {
                    this.dataSource = res.rows
                    this.pagination.total = res.total
                })
            },
        },

        setup() {
            const state = reactive({});

            function go(path) {
                this.$router.push({
                    path: path,
                    query: {
                        // id: id
                    },
                });
            }

            return {
                ...toRefs(state),
                go,
            };
        },
    });
</script>

<style scoped></style>
